package com.gao.security.verificationcode.storage;



import com.gao.security.verificationcode.entity.VerificationCode;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * <p>
 *    内存操作验证码--默认方式
 * </p>
 *
 * @author GaoShuangWen
 */

public class InMemoryVerificationCodeOperationManager implements VerificationCodeStorageManager {

    private Map<String,VerificationCode> map=Maps.newHashMap();
    @Override
    public boolean saveCode(VerificationCode code) {
        map.put(code.getCodeToken(),code);
        return true;
    }
    @Override
    public VerificationCode getCode(String key) {
        return map.get(key);
    }
    @Override
    public boolean remove(String key) {
        map.remove(key);
        return true;
    }

}
